<template>
	<view :class="[BackGround]" :style="[{'font-weight':Style,'font-family':Font,height:100 + '%',minHeight:height + 'px'}]">
		<cu-custom bgColor="bg-gradual-blue" isBack="true">
			<view slot="backText">返回</view>
			<view slot="content">补签</view>
		</cu-custom>
		<view :class="['margin-xs radius shadow shadow-lg bg-white' ,BackGroundBox]">
			<form @submit="formSubmit" @reset="formReset">
				<view :style="{marginBottom:100 + 'rpx'}">
					<view class="cu-form-group">
						<view class="title">姓名</view>
						<view class="action item-icon" @tap="jumpdetail">
							{{userinfo.LUSERNAME ? userinfo.LUSERNAME : '请选择'}}
						</view>
					</view>
					<view class="cu-form-group">
						<view class="title">员工号</view>
						<input type="text" disabled placeholder="根据姓名获得" :value="userinfo.LUSERCODE" name="LUSERCODE" />
					</view>
					<view class="cu-form-group">
						<view class="title">补签时间</view>
						<picker mode="date" @change="DateChange" start="1999-09-01" end="2999-09-01" name="LATEDATE" :value="date">
							<view class="picker">
								{{date}}
							</view>
						</picker>
					</view>
					<view class="cu-form-group">
						<view class="title">补签类型</view>
						<input type="text" disabled value="忘记打卡补签" name="LATETYPE" />
					</view>
					<view class="cu-form-group">
						<view class="title">补签原因</view>
						<textarea maxlength="-1" name="LREMARK" placeholder="请输入补签理由"></textarea>
					</view>
					<view class="cu-form-group">
						<view class="title">制单人</view>
						<input type="text" disabled :value="LMAKEOPID" name="LMAKEOPID" />
					</view>
					<view class="cu-form-group">
						<view class="title">制单日期</view>
						<input disabled name="LMAKEOPDATE" type="text" :value="date" />
					</view>
					
				</view>
				<button-father :Position="'tb-fa-fixed'">
					<button class="cu-btn bg-gradual-blue  lg shadow tb-flex cu-btn-new" form-type="submit">确认</button>
				</button-father>
			</form>
		</view>
	</view>
</template>

<script>
	import ButtonFather from "@/colorui/components/ButtonFather.vue";
	import {
		mapGetters,
		mapMutations
	} from "vuex";
	import {
		postinsertbq
	} from "@/service/insert.js"
	export default {
		data() {
			return {
				height:this.screenHeight,
				userinfo: '',
				index2: 0,
				myaddress: '',
				addressList: '',
				date: global.dateright,
				LMAKEOPID: global.userinfo.lusername,
				picker2: [{
					LNAME: '忘记打卡补签'
				}, {
					LNAME: "出差补签"
				}]
			}
		},
		onLoad() {

		},
		onShow() {},
		onUnload() {},
		components: {
			ButtonFather
		},
		computed: {
			...mapGetters(['Style', 'getitem', 'Font', 'BackGround','BackGroundBox'])
		},
		onShow() {
			if (this.getitem) {
				this.userinfo = this.getitem
			}
		},
		onUnload() {
			this.setitem('')
		},
		methods: {
			...mapMutations(['setitem']),
			//跳转选择员工页面
			jumpdetail() {
				uni.navigateTo({
					url: '../../personnel/Classassignment/Classassignmentdetail'
				})
			},
			DateChange(e) {
				this.date = e.detail.value
			},
			PickerChange2(e) {
				this.index2 = e.detail.value
			},
			formSubmit(e) {
				//定义表单规则
				var rule = [{
					name: "LUSERCODE",
					checkType: "notnull",
					errorMsg: "请选择员工"
				}];
				//进行表单检查
				var formData = e.detail.value;
				var checkRes = this.$graceChecker.check(formData, rule);
				if (!checkRes) {
					uni.showToast({
						title: this.$graceChecker.error,
						icon: "none"
					});
				} else {
					e.detail.value['LUSERNAME'] = this.userinfo.LUSERNAME
					e.detail.value['LUSERCODE'] = this.userinfo.LUSERCODE
					e.detail.value['LATETYPE'] = 1
					e.detail.value['LATEDATE'] = this.date
					e.detail.value['LMAKEOPID'] = global.userinfo.lusercode
					let model = e.detail.value
					console.log(e.detail.value);
					postinsertbq(model.LUSERCODE,model.LMAKEOPID,model.LREMARK, model.LATEDATE,model.LATETYPE, model.LMAKEOPDATE,
						model.LMAKEOPDATE).then(res => {
						if (res.code == 1) {
							setTimeout(() => {
								uni.navigateBack({
									delta: 1
								})
							},500)
							uni.showToast({
								title: '成功',
								icon: "success",
								duration: 3000
							})
						} else {
							uni.showToast({
								title: '打卡失败',
								icon: 'none'
							})
						}
					})
				}
			},
			
		}
	}
</script>

<style>

</style>
